import base.stockbase as sb

# 同步基础信息表
# 以akshare的为准
# akshare里有而存储的数据里没有，视为新增，需要增加相应的数据存储基础信息、日线、周线、月线
# 存储的数据里有而akshare没有，视为删除，需要删除响应的数据存储基础信息、日线、周线、月线


def sync_stock_basic():
    ak_stock_basic = sb.fetch_all_a_stocks()
    saved_stock_basic = sb.get_stock_basic()
    ak_codes = ak_stock_basic['code'].values
    saved_symbols = saved_stock_basic['symbol'].values
    # 新增的股票
    add_stocks = list(set(ak_codes) - set(saved_symbols))
    # 删除的股票
    del_stocks = list(set(saved_symbols) - set(ak_codes))
    print(f'新增的股票:{add_stocks}')
    print(f'删除的股票:{del_stocks}')
    return


def main():
    sync_stock_basic()
    return


if __name__ == "__main__":
    main()
